﻿using System;
using System.ComponentModel.DataAnnotations;
using Dgg.Anug.Cqrs.Core.Application.Admin.Commands;
using Dgg.Anug.Cqrs.Core.Infrastructure.Validation;
using NUnit.Framework;

namespace Dgg.Anug.Cqrs.Core.Tests.Infrastructure.Validation
{
	[TestFixture]
	public class AssignVersionValidationTester
	{
		[Test]
		public void Null_Invalid()
		{
			ValidationService subject = new ValidationService();
			AssignVersion @null = null;
			Assert.That(() => subject.AssertValidity(@null), Throws.InstanceOf<ArgumentNullException>());
		}

		[Test]
		public void BothIdsPopulated_Valid()
		{
			ValidationService subject = new ValidationService();
			AssignVersion bothPopulated = new AssignVersion(new Guid("4750a5cb-841d-4218-961e-0a4f146bac38"), new Guid("4750a5cb-841d-4218-961e-0a4f146bac38"));
			Assert.That(() => subject.AssertValidity(bothPopulated), Throws.Nothing);
		}

		[Test]
		public void SolutionIdNotPopulated_Valid()
		{
			ValidationService subject = new ValidationService();
			AssignVersion bothPopulated = new AssignVersion(new Guid("4750a5cb-841d-4218-961e-0a4f146bac38"), Guid.Empty);
			Assert.That(() => subject.AssertValidity(bothPopulated), Throws.Nothing);
		}

		[Test]
		public void IdNotPopulated_Invalid()
		{
			ValidationService subject = new ValidationService();
			AssignVersion bothPopulated = new AssignVersion(Guid.Empty, new Guid("4750a5cb-841d-4218-961e-0a4f146bac38"));
			Assert.That(() => subject.AssertValidity(bothPopulated), Throws.InstanceOf<ValidationException>());
		}
	}
}
